#ifndef COURSEFACTORY_H_
#define COURSEFACTORY_H_

#include "course.h"
#include <boost/shared_ptr.hpp>
#include <map>
#include <utility>
#include <string>

/// Singleton flyweight-factory of Course objects.
class CourseFactory {
	boost::shared_ptr<struct CourseFactoryImpl> pimpl_;
    static CourseFactory* instance_;
	
	typedef std::pair<std::string, boost::shared_ptr<Course> > pool_pair;
    
public:
	typedef std::map<std::string, boost::shared_ptr<Course> > pool_type;
	typedef std::pair<pool_type::iterator, pool_type::iterator> pool_range;

	virtual ~CourseFactory();

    static CourseFactory* instance();
	boost::shared_ptr<Course> get(const std::string&);
	boost::shared_ptr<Course> get(const Course&);
	pool_range pool() const;

private:
	CourseFactory();
    CourseFactory(const CourseFactory&);
    CourseFactory& operator=(const CourseFactory&);
    
	pool_type& flyweights() const;
};

#endif
